package com.wenlin.myproduction.binder;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.bean.ScheduleTopTotalBean;
import com.wenlin.myproduction.util.UI;

import me.drakeet.multitype.ItemViewBinder;

/**
 * @author 文琳_377979485@qq.com
 * @time 2021/10/15 0015 下午 3:38
 * @desc 排班管理的上侧列表第二种条目——统计条目，即夜班数和上班时长条目。
 */
public class ScheduleTopTotalBinder extends ItemViewBinder<ScheduleTopTotalBean, ScheduleTopTotalBinder.ScheduleTopTotalHolder> {


    @NonNull
    @Override
    protected ScheduleTopTotalHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        return new ScheduleTopTotalHolder(inflater.inflate(R.layout.item_schedule_top_total, parent, false));
    }

    @Override
    protected void onBindViewHolder(@NonNull ScheduleTopTotalHolder holder, @NonNull ScheduleTopTotalBean item) {
        UI.setText(holder.tv, item.getName());
        UI.setVisibleInvisible(holder.v, item.getName().contains("夜班"));
    }

    static class ScheduleTopTotalHolder extends RecyclerView.ViewHolder {
        TextView tv;
        View v;

        public ScheduleTopTotalHolder(@NonNull View itemView) {
            super(itemView);
            tv = itemView.findViewById(R.id.tv);
            v = itemView.findViewById(R.id.v);
        }
    }
}
